package com.qlm.service;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.qlm.model.userTable;

public class userService {

	private Connection con;
	private PreparedStatement pstmt;
	public userService(){
		con = new com.qlm.conn.conn().getCon();
	}
	
	public boolean valiUser(userTable user) throws SQLException{
		try {
			pstmt = con.prepareStatement("select * from usertable where username=? and password=?");
			pstmt.setString(1, user.getUsername());
			pstmt.setString(2, user.getPassword());
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}
		ResultSet rs = pstmt.executeQuery();
		try{
			if(rs.next())
				return true;
			else
				return false;
		}finally{
			rs.close();
		}
	}
}
